package cn.com.mall.search.controller;

import cn.com.mall.common.dto.es.SkuEsModel;
import cn.com.mall.common.utils.R;
import cn.com.mall.search.service.ProductSaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/search/save")
public class ElasticSaveController {

    @Autowired
    ProductSaveService productSaveService;

    @PostMapping("/product")
    public R productStatusUp(@RequestBody List<SkuEsModel> skuEsModelList){
        try {
            productSaveService.productStatusUp(skuEsModelList);
        } catch (IOException e) {
            return R.error(-1,"上架出现异常");
        }
        return R.ok();
    }
}
